/**
 * 
 */
package tests;

import domain.*;


/**
 * @author it-equipment-selection team
 *
 */
public class AddVotesTest {
	
	public static void main(String[] args) {
		BallotBox urna = BallotBox.getInstance();
		User u1, u2, u3;
		u1 = new User ("user","u001","p001","Luis");
		u2 = new User ("user","u002","p002","Daniel");
		u3 = new User ("user","u003","p003","Aquivaldo");
		Article printer = new Article("Impresora","2345","25/ISE1/2007");
		Article computer = new Article("Ordenador","4562","25/ISE1/2007");
		Article laptop = new Article("Portatil","2112","25/ISE1/2007");
		Supplier hp = new Supplier(1023,"Las Rozas, Madrid","HP España","zonasur.comercial@hp.es",0.9);
		Product p1, p2, p3, p4, p5, p6;
		p1 = new LocalPrinter("Samsung","ML-1510", 88.50, printer, hp, 8, false, false, false, true);
		p2 = new LocalPrinter("HP","Laserjet 1020", 98.15, printer, hp, 10, false, false, false, false);
		p3 = new Computer("HP","Pavilion M8175", 281.90, computer, hp, "AMD 64", 2048, 80, 19, false);
		p4 = new Laptop("Toshiba","Satellite A-200", 599.90, laptop, hp, "Intel Centrino", 1024, 160, 15.4, true, 400, 2.5 );
		p5 = new Laptop("Toshiba","Satellite A-200", 599.90, laptop, hp, "Intel Centrino", 1024, 160, 15.4, true, 480, 3.5 );
		p6 = new Laptop("Toshiba","Satellite A-210", 699.90, laptop, hp, "Intel Core", 2048, 250, 15.4, true, 600, 2.1 );
		p1.doValidate();
		p2.doValidate();
		p3.doValidate();
		p4.doValidate();
		p5.doValidate();
		p6.doValidate();
		try {
			urna.addVote(u1, p1);
			System.out.println("Usuario " + u1.getId() + " vota producto " + p1.getModel() + ". NumVotos p1 = " + p1.getNumVotes());
		} catch (Exception e) {
			System.out.println("Voto invalido");
		}
		try {
			urna.addVote(u1, p2);
		} catch (Exception e) {
			System.out.println("Voto invalido");
		}
		try {
			urna.addVote(u1, p3);
			
		} catch (Exception e) {
			System.out.println("Voto invalido");
		}
		try {
			urna.addVote(u1, p5);
			System.out.println("Usuario" + u1.getId() + "vota producto" + p5.getModel() + ". NumVotos p5 = " + p5.getNumVotes());
		} catch (Exception e) {
			System.out.println("Voto invalido");
		}
		try {
			urna.addVote(u1, p6);
			System.out.println("Usuario 1 vota producto 6. NumVotos p6 = " + p6.getNumVotes());
		} catch (Exception e) {
			System.out.println("Voto invalido");
		}
		try {
			urna.addVote(u2, p6);
			System.out.println("Usuario 2 vota producto 6. NumVotos p6 = " + p6.getNumVotes());
		} catch (Exception e) {
			System.out.println("Voto invalido");
		}
		try {
			urna.addVote(u3, p2);
			System.out.println("Usuario" + u3.getName() + "vota producto" + p2.getModel() + ". NumVotos p2 = " + p2.getNumVotes());
		} catch (Exception e) {
			System.out.println("Voto invalido");
		}
		try {
			urna.addVote(u3, p1);
			System.out.println("Usuario " + u3.getName() + " vota producto " + p1.getModel() + ". NumVotos p1 = " + p1.getNumVotes());
		} catch (Exception e) {
			System.out.println("Voto invalido");
		}
	}

}
